<!--
 * @Date: 2019-12-25 08:54:21
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-05-06 17:33:35
 * @describe: -跟进列表-
 -->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-house__housefollow}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <!-- <el-form-item>
            <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
            </el-form-item>
            <el-form-item>
            <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>-->
        <!-- <el-form-item>
            <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item>-->
        <!-- <el-form-item>
          <el-button
            v-if="hasPermissionInfo('house:houseinfofollow:save')&&$hasPermission('house:houseinfofollow:save')"
            type="primary"
            @click="addOrUpdateHandle()"
          >{{ $t('add') }}</el-button>
        </el-form-item>-->
        <el-form-item>
          <el-button
            v-if="hasPermissionInfo('house:houseinfofollow:delete')&&$hasPermission('house:houseinfofollow:delete')"
            type="danger"
            @click="deleteHandle()"
          >{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border style="width: 100%;">
        <!-- <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column> -->
        <!-- <el-table-column prop="id" label="主键" header-align="center" align="center"></el-table-column>
        <el-table-column prop="fjId" label="房间Id" header-align="center" align="center"></el-table-column>
        <el-table-column prop="houseId" label="房源id" header-align="center" align="center"></el-table-column>-->
        <el-table-column prop="content" label="跟进内容" header-align="center" align="center"></el-table-column>
        <el-table-column prop="extranet" label="外网同步" header-align="center" align="center">
          <template slot-scope="scope">
            <el-switch
              class="switchStyle"
              v-model="scope.row.extranet"
              @change="tabExamineChange(scope.row)"
              :active-value="1"
              :inactive-value="0"
              :disabled="!$hasPermission('house:houseinfofollow:extranet')"
            ></el-switch>
          </template>
        </el-table-column>
        <!-- <el-table-column prop="deptId" label="部门Id" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="creatorName" label="跟进人" header-align="center" align="center"></el-table-column>
        <el-table-column prop="deptName" label="跟进人部门" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createDate" label="跟进时间" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column
                    :label="$t('handle')"
                    fixed="right"
                    header-align="center"
                    align="center"
                    width="150"
                >
                    <template slot-scope="scope">
                        <el-button
                            v-if="$hasPermission('house:housefollow:update')"
                            type="text"
                            size="small"
                            @click="addOrUpdateHandle(scope.row.id)"
                        >{{ $t('update') }}</el-button>
                        <el-button
                            v-if="$hasPermission('house:housefollow:delete')"
                            type="text"
                            size="small"
                            @click="deleteHandle(scope.row.id)"
                        >{{ $t('delete') }}</el-button>
                    </template>
        </el-table-column>-->
      </el-table>
      <div class="paginationBox">
        <el-pagination
          :current-page="page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="limit"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="pageSizeChangeHandle"
          @current-change="pageCurrentChangeHandle"
        ></el-pagination>
      </div>
      <!-- 弹窗, 新增 / 修改 -->
      <!-- <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> -->
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
// import AddOrUpdate from './housefollow-add-or-update'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/house/housefollow/page",
        getDataListIsPage: true,
        exportURL: "/house/housefollow/export",
        deleteURL: "/house/housefollow",
        deleteIsBatch: true
      },
      dataForm: {
        houseId: this.HousingID,
        type: 2
      }
    };
  },
  props: ["HousingID", "permissionListDTO"],
  components: {
    // AddOrUpdate
  },
  methods: {
    //审核
    tabExamineChange(row) {
      this.$http
        .put(
          `/house/housefollow/updateExtranet`,
          {},
          {
            params: {
              id: row.id,
              extranet: row.extranet
            }
          }
        )
        .then(({ data: res }) => {
          if (res.code !== 0) {
            this.getDataList();
            return this.$message.error(res.msg);
          }
          this.$message.success("更改成功");
        })
        .catch(() => {});
    },
    //判断操作权限
    hasPermissionInfo(val) {
      let _this = this;
      let arr = _this.permissionListDTO;
      if (arr && arr != []) {
        for (let i = 0; i < arr.length; i++) {
          const element = arr[i];
          if (element.permission.indexOf(val) != -1 && element.state == true) {
            return true;
          }
        }
      } else {
        return false;
      }
    }
  },
  watch: {
    HousingID: {
      handler(newValue, oldValue) {
        this.dataForm.houseId = newValue;
        this.query();
      }
    }
  }
};
</script>
